using System;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace Oracle.ManagedDataAccess.Types
{
	[Serializable]
	[XmlSchemaProvider("GetXsdType")]
	public struct OracleIntervalYM : IComparable, INullable, IXmlSerializable
	{
		private static uint INTYMYEAROFFSET = 2147483648u;

		private static uint INTYMMONTHOFFSET = 60u;

		private bool m_bNotNull;

		private byte m_yearPrec;

		private byte[] m_byteRepresentation;

		internal const short MaxArrSize = 5;

		internal const byte IYMType = 7;

		internal const byte YEAR = 0;

		internal const byte MONTH = 1;

		public static readonly OracleIntervalYM MaxValue = new OracleIntervalYM(999999999, 11);

		public static readonly OracleIntervalYM MinValue = new OracleIntervalYM(-999999999, -11);

		public static readonly OracleIntervalYM Zero = new OracleIntervalYM(0, 0);

		public static readonly OracleIntervalYM Null;

		public byte[] BinData
		{
			get
			{
				if (m_bNotNull)
				{
					byte[] array = new byte[5];
					if (m_byteRepresentation != null)
					{
						Array.Copy(m_byteRepresentation, array, 5);
					}
					return array;
				}
				throw new OracleNullValueException();
			}
		}

		public bool IsNull => !m_bNotNull;

		public long Value
		{
			get
			{
				if (m_bNotNull)
				{
					return GetLong(m_byteRepresentation, OracleDbType.IntervalYM);
				}
				throw new OracleNullValueException();
			}
		}

		public int Years
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIYMData(m_byteRepresentation, 0);
				}
				throw new OracleNullValueException();
			}
		}

		public int Months
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIYMData(m_byteRepresentation, 1);
				}
				throw new OracleNullValueException();
			}
		}

		public double TotalYears
		{
			get
			{
				if (m_bNotNull)
				{
					return (double)GetIYMData(m_byteRepresentation, 0) + (double)GetIYMData(m_byteRepresentation, 1) / 12.0;
				}
				throw new OracleNullValueException();
			}
		}

		internal byte[] InternalByteRepresentation => m_byteRepresentation;

		public OracleIntervalYM(int years, int months)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				if (Interval.IsValidYM(years, months))
				{
					m_bNotNull = true;
					m_yearPrec = 9;
					m_byteRepresentation = new byte[5];
					years += (int)INTYMYEAROFFSET;
					m_byteRepresentation[0] = RepConversion.RightShiftFirstNibble(years);
					m_byteRepresentation[1] = RepConversion.RightShiftSecondNibble(years);
					m_byteRepresentation[2] = RepConversion.RightShiftThirdNibble(years);
					m_byteRepresentation[3] = RepConversion.RightShiftFourthNibble(years);
					m_byteRepresentation[4] = (byte)(months + INTYMMONTHOFFSET);
					return;
				}
				throw new ArgumentOutOfRangeException();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleIntervalYM(long totalMonths)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				if (Interval.IsValidYMMonths(totalMonths))
				{
					m_bNotNull = true;
					m_byteRepresentation = new byte[5];
					m_yearPrec = 9;
					int num = (int)(totalMonths / 12);
					int num2 = (int)(totalMonths % 12);
					num += (int)INTYMYEAROFFSET;
					m_byteRepresentation[0] = RepConversion.RightShiftFirstNibble(num);
					m_byteRepresentation[1] = RepConversion.RightShiftSecondNibble(num);
					m_byteRepresentation[2] = RepConversion.RightShiftThirdNibble(num);
					m_byteRepresentation[3] = RepConversion.RightShiftFourthNibble(num);
					m_byteRepresentation[4] = (byte)(num2 + INTYMMONTHOFFSET);
					return;
				}
				throw new ArgumentOutOfRangeException("totalMonths");
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleIntervalYM(double totalYears)
			: this((int)totalYears, (int)Math.Ceiling((totalYears - (double)(int)totalYears) * 12.0))
		{
		}

		public OracleIntervalYM(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				if (intervalStr == null)
				{
					throw new ArgumentNullException("intervalStr");
				}
				if (intervalStr.Length == 0)
				{
					throw new FormatException("intervalStr");
				}
				m_bNotNull = true;
				m_yearPrec = 9;
				m_byteRepresentation = null;
				m_byteRepresentation = ToBytes(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleIntervalYM(byte[] binData)
			: this(binData, bCopyData: true)
		{
		}

		internal OracleIntervalYM(byte[] binData, int precision, bool bCopyData = true)
			: this(binData, bCopyData)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				int num = GetIYMData(m_byteRepresentation, 0);
				if (num < 0)
				{
					num = -num;
				}
				if (num != 0 && num.ToString().Length > precision)
				{
					throw new OverflowException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.YEAR_OUT_OF_RANGE));
				}
				m_yearPrec = (byte)precision;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		internal OracleIntervalYM(byte[] binData, bool bCopyData)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				if (binData == null)
				{
					throw new ArgumentNullException("binData");
				}
				m_bNotNull = true;
				m_yearPrec = 9;
				if (binData.Length != 5)
				{
					throw new ArgumentException("binData");
				}
				if (bCopyData)
				{
					m_byteRepresentation = new byte[5];
					Array.Copy(binData, m_byteRepresentation, 5);
				}
				else
				{
					m_byteRepresentation = binData;
				}
				int iYMData = GetIYMData(m_byteRepresentation, 0);
				int iYMData2 = GetIYMData(m_byteRepresentation, 1);
				if (!Interval.IsValidYM(iYMData, iYMData2))
				{
					throw new ArgumentOutOfRangeException();
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public static bool Equals(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Equals);
			}
			try
			{
				return InternalTypes.CompareNull(!value1.m_bNotNull, !value2.m_bNotNull) switch
				{
					CompareNullEnum.BothNull => true, 
					CompareNullEnum.BothNotNull => value1.CompareTo(value2) == 0, 
					_ => false, 
				};
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Equals);
				}
			}
		}

		public static bool GreaterThan(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GreaterThan);
			}
			try
			{
				return value1.CompareTo(value2) > 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GreaterThan);
				}
			}
		}

		public static bool GreaterThanOrEqual(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GreaterThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) >= 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GreaterThanOrEqual);
				}
			}
		}

		public static bool LessThan(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.LessThan);
			}
			try
			{
				return value1.CompareTo(value2) < 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.LessThan);
				}
			}
		}

		public static bool LessThanOrEqual(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.LessThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) <= 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.LessThanOrEqual);
				}
			}
		}

		public static bool NotEquals(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.NotEquals);
			}
			try
			{
				return value1.CompareTo(value2) != 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.NotEquals);
				}
			}
		}

		public static OracleIntervalYM Parse(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Parse);
			}
			try
			{
				return new OracleIntervalYM(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Parse, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Parse);
				}
			}
		}

		public static OracleIntervalYM SetPrecision(OracleIntervalYM value1, int yearPrecision)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.SetPrecision);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					throw new OracleNullValueException();
				}
				if (yearPrecision < 0 || yearPrecision > 9)
				{
					throw new ArgumentOutOfRangeException("yearPrecision");
				}
				return new OracleIntervalYM(value1.InternalByteRepresentation, yearPrecision);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.SetPrecision, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.SetPrecision);
				}
			}
		}

		public static bool operator ==(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorEqualTo);
			}
			try
			{
				return Equals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorEqualTo);
				}
			}
		}

		public static bool operator >(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorGreaterThan);
			}
			try
			{
				return GreaterThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorGreaterThan);
				}
			}
		}

		public static bool operator >=(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
			}
			try
			{
				return GreaterThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
				}
			}
		}

		public static bool operator <(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLessThan);
			}
			try
			{
				return LessThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLessThan);
				}
			}
		}

		public static bool operator <=(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLessThanOrEqualTo);
			}
			try
			{
				return LessThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLessThanOrEqualTo);
				}
			}
		}

		public static bool operator !=(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorNotEqualTo);
			}
			try
			{
				return NotEquals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorNotEqualTo);
				}
			}
		}

		public static OracleIntervalYM operator +(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorPlus);
			}
			try
			{
				if (!value1.m_bNotNull || !value2.m_bNotNull)
				{
					return Null;
				}
				long totalMonth = GetTotalMonth(value1);
				long totalMonth2 = GetTotalMonth(value2);
				return new OracleIntervalYM(totalMonth + totalMonth2);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorPlus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorPlus);
				}
			}
		}

		public static OracleIntervalYM operator -(OracleIntervalYM value1, OracleIntervalYM value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus);
			}
			try
			{
				if (!value1.m_bNotNull || !value2.m_bNotNull)
				{
					return Null;
				}
				long totalMonth = GetTotalMonth(value1);
				long totalMonth2 = GetTotalMonth(value2);
				return new OracleIntervalYM(totalMonth - totalMonth2);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus);
				}
			}
		}

		public static OracleIntervalYM operator -(OracleIntervalYM value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				int iYMData = GetIYMData(value1.InternalByteRepresentation, 0);
				int iYMData2 = GetIYMData(value1.InternalByteRepresentation, 1);
				return new OracleIntervalYM(-iYMData, -iYMData2);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMinus);
				}
			}
		}

		public static OracleIntervalYM operator *(OracleIntervalYM value1, int multiplier)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMultiply);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				return new OracleIntervalYM(GetTotalMonth(value1) * multiplier);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMultiply, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorMultiply);
				}
			}
		}

		public static OracleIntervalYM operator /(OracleIntervalYM value1, int divisor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorDivide);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				if (divisor == 0)
				{
					throw new DivideByZeroException();
				}
				return new OracleIntervalYM(GetTotalMonth(value1) / divisor);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorDivide, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorDivide);
				}
			}
		}

		public static explicit operator OracleIntervalYM(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleIntervalYM(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public static explicit operator long(OracleIntervalYM value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLong);
			}
			try
			{
				return GetTotalMonth(value1);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLong, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.OperatorLong);
				}
			}
		}

		public static implicit operator OracleIntervalYM(long months)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleIntervalYM(months);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ctor);
				}
			}
		}

		public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
		{
			return new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
		}

		XmlSchema IXmlSerializable.GetSchema()
		{
			return null;
		}

		void IXmlSerializable.ReadXml(XmlReader reader)
		{
			if (reader == null)
			{
				throw new ArgumentNullException("reader");
			}
			string attribute = reader.GetAttribute("null", "http://www.w3.org/2001/XMLSchema-instance");
			if (attribute == null || !XmlConvert.ToBoolean(attribute))
			{
				attribute = reader.ReadElementString();
				if (attribute == null || attribute.Length == 0)
				{
					throw new FormatException();
				}
				m_bNotNull = true;
				m_yearPrec = 9;
				m_byteRepresentation = ToBytes(attribute);
			}
			else
			{
				m_bNotNull = false;
			}
		}

		void IXmlSerializable.WriteXml(XmlWriter writer)
		{
			if (m_bNotNull)
			{
				writer.WriteString(ToString());
			}
			else
			{
				writer.WriteAttributeString("xsi", "null", "http://www.w3.org/2001/XMLSchema-instance", "true");
			}
		}

		public int CompareTo(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.CompareTo);
			}
			try
			{
				if (obj == null)
				{
					throw new ArgumentNullException("obj");
				}
				if (obj.GetType() != typeof(OracleIntervalYM))
				{
					throw new ArgumentException("obj");
				}
				OracleIntervalYM oracleIntervalYM = (OracleIntervalYM)obj;
				switch (InternalTypes.CompareNull(!m_bNotNull, !oracleIntervalYM.m_bNotNull))
				{
				case CompareNullEnum.BothNull:
					return 0;
				case CompareNullEnum.FirstNullOnly:
					return -1;
				case CompareNullEnum.SecondNullOnly:
					return 1;
				default:
				{
					byte[] internalByteRepresentation = oracleIntervalYM.InternalByteRepresentation;
					for (int i = 0; i < m_byteRepresentation.Length; i++)
					{
						if (m_byteRepresentation[i] != internalByteRepresentation[i])
						{
							if (m_byteRepresentation[i] < internalByteRepresentation[i])
							{
								return -1;
							}
							return 1;
						}
					}
					return 0;
				}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.CompareTo, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.CompareTo);
				}
			}
		}

		public override string ToString()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToString);
			}
			try
			{
				if (m_bNotNull)
				{
					bool flag = true;
					int num = GetIYMData(m_byteRepresentation, 0);
					int num2 = GetIYMData(m_byteRepresentation, 1);
					if (num < 0)
					{
						flag = false;
						num = -num;
					}
					if (num2 < 0)
					{
						flag = false;
						num2 = -num2;
					}
					StringBuilder stringBuilder = new StringBuilder(15);
					string text = num.ToString();
					string text2 = num2.ToString();
					int length = text.Length;
					if (length < m_yearPrec)
					{
						text = HelperClass.GetZeros(m_yearPrec - length) + text;
					}
					else if (length > m_yearPrec)
					{
						text = text.Substring(0, m_yearPrec);
					}
					if (num2 < 10)
					{
						text2 = "0" + text2;
					}
					if (flag)
					{
						stringBuilder.Append("+");
					}
					else
					{
						stringBuilder.Append("-");
					}
					if (text.Length == 0)
					{
						stringBuilder.Append("0");
					}
					else
					{
						stringBuilder.Append(text);
					}
					stringBuilder.Append("-");
					stringBuilder.Append(text2);
					return stringBuilder.ToString();
				}
				return "null";
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToString, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToString);
				}
			}
		}

		public override bool Equals(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Equals);
			}
			try
			{
				if (obj == null || obj.GetType() != typeof(OracleIntervalYM))
				{
					return false;
				}
				return CompareTo(obj) == 0;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Equals, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.Equals);
				}
			}
		}

		public override int GetHashCode()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetHashCode);
			}
			try
			{
				if (m_bNotNull)
				{
					return m_byteRepresentation.GetHashCode();
				}
				return 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetHashCode);
				}
			}
		}

		internal byte[] ToBytes(string intervalYM)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToBytes);
			}
			try
			{
				byte[] array = new byte[5];
				string text = intervalYM.Trim();
				char c = text[0];
				int startIndex = 0;
				if (c == '-' || c == '+')
				{
					startIndex = 1;
				}
				text = text.Substring(startIndex);
				int num = text.IndexOf('-');
				if (num < 0)
				{
					throw new FormatException();
				}
				string text2 = text.Substring(0, num);
				if (text2.Length > m_yearPrec)
				{
					throw new FormatException();
				}
				int num2 = int.Parse(text2);
				int num3 = int.Parse(text.Substring(num + 1));
				if (num3 > 11)
				{
					throw new FormatException();
				}
				if (c == '-')
				{
					num2 = -1 * num2;
					num3 = -1 * num3;
				}
				num2 += (int)INTYMYEAROFFSET;
				array[0] = RepConversion.RightShiftFirstNibble(num2);
				array[1] = RepConversion.RightShiftSecondNibble(num2);
				array[2] = RepConversion.RightShiftThirdNibble(num2);
				array[3] = RepConversion.RightShiftFourthNibble(num2);
				array[4] = (byte)(num3 + INTYMMONTHOFFSET);
				return array;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToBytes, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.ToBytes);
				}
			}
		}

		internal static int GetIYMData(byte[] byteRepresentation, byte iymComponent, int dataOffset = 0)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetIYMData);
			}
			try
			{
				int result = 0;
				switch (iymComponent)
				{
				case 0:
					result = RepConversion.LeftShiftFirstNibble(byteRepresentation[dataOffset]);
					result |= RepConversion.LeftShiftSecondNibble(byteRepresentation[1 + dataOffset]);
					result |= RepConversion.LeftShiftThirdNibble(byteRepresentation[2 + dataOffset]);
					result |= byteRepresentation[3 + dataOffset] & 0xFF;
					result -= (int)INTYMYEAROFFSET;
					break;
				case 1:
					result = (int)(byteRepresentation[4 + dataOffset] - INTYMMONTHOFFSET);
					break;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetIYMData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetIYMData);
				}
			}
		}

		internal static long GetLong(byte[] byteRepresentation, OracleDbType oraType, int dataOffset = 0, int dataLength = -1)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetLong);
			}
			try
			{
				if (dataLength == -1)
				{
					dataLength = byteRepresentation.Length;
				}
				if (oraType != OracleDbType.IntervalYM || dataLength != 5)
				{
					throw new OracleTypeException(ResourceStringConstants.INT_ERR);
				}
				return (long)GetIYMData(byteRepresentation, 0, dataOffset) * 12L + GetIYMData(byteRepresentation, 1, dataOffset);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetLong, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetLong);
				}
			}
		}

		internal static long GetTotalMonth(OracleIntervalYM value)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetTotalMonth);
			}
			try
			{
				int iYMData = GetIYMData(value.InternalByteRepresentation, 0);
				int iYMData2 = GetIYMData(value.InternalByteRepresentation, 1);
				return (long)iYMData * 12L + iYMData2;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetTotalMonth, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalYM, OracleTraceFuncName.GetTotalMonth);
				}
			}
		}
	}
}
